package com.tcp1;

import java.io.DataOutputStream;
import java.net.Socket;

public class TCPClient {
    public static void main(String[] args) {
        // 实现TCP一发一收
        System.out.println("======客户端启动======");
        // 创建TCP客户端 java.net.Socket
        try(Socket socket = new Socket("127.0.0.1", 9999)) {
            // 获取特殊数据流
            DataOutputStream outputStream = new DataOutputStream(socket.getOutputStream());
            outputStream.writeInt(1);
            outputStream.writeUTF("这是一个TCP数据包发送的单例模式");
        } catch (Exception e) {
            System.out.println("发送TCP数据失败！");
            e.printStackTrace();
        }

    }
}
